package com.tencent.cloud.iov.common.block.item.impl;

import com.tencent.cloud.iov.common.R;
import com.tencent.cloud.iov.common.block.item.IRefreshNoticeBlockItem;
import com.tencent.cloud.iov.util.DateTimeUtils;
import com.tencent.cloud.iov.util.ObjectUtils;
import com.tencent.cloud.iov.util.ResourcesUtils;

/**
 * @author showxiao
 * @date 2018/8/10
 */
public class RefreshNoticeBlockItem implements IRefreshNoticeBlockItem {

    public static final String DATE_FORMAT = "MM-dd HH:mm";

    private CharSequence mResultNotice;
    private CharSequence mRefreshingNotice;

    public RefreshNoticeBlockItem(long refreshTime) {
        if (refreshTime <= 0L) {
            mResultNotice = ResourcesUtils.getString(R.string.pull_to_refresh_with_no_data);
        } else {
            mResultNotice = ResourcesUtils.getString(R.string.refresh_notice,
                    DateTimeUtils.getDateTime(refreshTime, DATE_FORMAT));
        }
        mRefreshingNotice = ResourcesUtils.getString(R.string.refreshing_notice);
    }

    @Override
    public CharSequence getResultNotice() {
        return mResultNotice;
    }

    @Override
    public CharSequence getRefreshingNotice() {
        return mRefreshingNotice;
    }

    public void setResultNotice(CharSequence resultNotice) {
        mResultNotice = resultNotice;
    }

    public void setRefreshingNotice(CharSequence refreshingNotice) {
        mRefreshingNotice = refreshingNotice;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RefreshNoticeBlockItem that = (RefreshNoticeBlockItem) o;
        return ObjectUtils.equals(mResultNotice, that.mResultNotice);
    }

    @Override
    public int hashCode() {
        return ObjectUtils.hash(mResultNotice);
    }
}
